#ifndef IMAGEVIEW_H
#define IMAGEVIEW_H

#include <QWidget>

#define SystemTaskBarHeight (qApp->primaryScreen()->geometry().height() - qApp->primaryScreen()->availableGeometry().height())
#define PrimaryScreenGeometry (qApp->primaryScreen()->geometry())

class ImageView : public QWidget
{
    Q_OBJECT
public:
    explicit ImageView(QWidget *parent = nullptr);

    void setPixmap(const QImage &image);

    void save();

    void flipvertical();

protected:
    void paintEvent(QPaintEvent *event) override;
    void wheelEvent(QWheelEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;

private:
    void updateViewInfo();

private:
    QImage image;
    qreal scaleFactor = 1;

    QPoint posCur = {0, 0};
    QPoint posOff = {0, 0};
    QPoint posPressed = {};

    bool isPressed = false;
    bool isflipvertical = false;
};

#endif // IMAGEVIEW_H
